/*
 * Created on 03.05.2006
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package ro.qi.framework.sys.users.profile.entities;

/**
 * @author Luiza Varovici
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */

import java.util.Hashtable;
import java.util.Vector;

import ro.qi.framework.sys.entities.Entity;

public class UsersAccountProfile extends Entity {

	public UsersAccountProfile() {
		super();
	}

	public UsersAccountProfile(Integer id) {
		super();
		setValue("userId", id);
		select();
	}

	public UsersAccountProfile(int id) {
		super();
		setValue("userId", new Integer(id));
		select();
	}

	public void setUserId(int value) {
		setValue("userId", new Integer(value));
	}

	public int getUserId() {
		return ((Integer)getValue("userId")).intValue();
	}

	public int getNoResponses() {
		return ((Vector)getValue("responses")).size();
	}
	
	public int getResponseId(int index) {
		if( index < getNoResponses() ) {
			Hashtable tmp = (Hashtable)(((Vector)getValue("responses")).get(index));
			if( tmp.containsKey("responseId") )
				return Integer.parseInt(tmp.get("responseId").toString());
		}
		return 0;
	}
	
	public UsersAccountProfileResponse getResponse(int index) {
		int responseId = getResponseId(index);
		if( responseId > 0 )
			return new UsersAccountProfileResponse(responseId);
		return null;
	}

}

